﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HPortal.Lib;
using System.Data;
using System.Data.SqlClient;
using System.Web.Security;

namespace HPortal.Backend
{
    public partial class TaoTaikhoanChunhiem : System.Web.UI.Page
    {
        public int ArticleID = HtmlHelper.GetIdFromRequestString("ArticleID", -1);
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void cmdCreateUser_Click(object sender, EventArgs e)
        {
            DataTable dt = DatabaseHelper.Select("SELECT [TenDangnhap] FROM KH_Nguoidung WHERE [TenDangnhap] not in (SELECT UserName FROM aspnet_Users)");
            int c = dt.Rows.Count;
            for (int i = 0; i < c; i++)
            {
                Membership.CreateUser(dt.Rows[i][0].ToString(), dt.Rows[i][0].ToString() + "12#");
                Roles.AddUserToRole(dt.Rows[i][0].ToString(), "ChunhiemDetai");
            }
            //String VuKHCNRole = System.Configuration.ConfigurationManager.AppSettings["VuKHCNRole"].ToString();

            //DataTable dt1 = DatabaseHelper.Select("SELECT UserName FROM aspnet_Users Where UserID not IN (Select UserID From aspnet_UsersInRoles Where RoleID IN (Select RoleID From aspnet_Roles Where RoleName='" + VuKHCNRole +"'))");
            //int c1 = dt1.Rows.Count;
            //for (int i = 0; i < c1; i++)
            //{
            //    Roles.AddUserToRole(dt1.Rows[i][0].ToString(), "ChunhiemDetai");
            //}
        }
    }
}